package com.ldq.imooc.basics.socket;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @Author : 李道泉
 * @Description :
 * @Date : 2018/4/23 13:51
 * @Modified by :
 */
public class NetTest2 {

    public static void main(String[] args) {

        try {
            URL imooc = new URL("http://www.imooc.com");
            URL url = new URL(imooc, "/index.html?username=tom#test");
            System.out.println("协议:" + url.getProtocol());
            System.out.println("主机:" + url.getHost());
            System.out.println("端口:" + url.getPort());
            System.out.println("文件路径:" + url.getPath());
            System.out.println("文件名:" + url.getFile());
            System.out.println("相对路径:" + url.getRef());
            System.out.println("查询字符串:" + url.getQuery());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

    }
}
